package kr.co.goodwilldd.framework.cons;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <pre>
 * View에서 공통적으로 사용하게 될 전역 변수를 설정
 * </pre>
 * 
 * @author GoodwillDD (kr.goodwilldd@gmail.com)
 * 
 */
public class FCommonCons implements Filter {

	private static final Logger logger = LoggerFactory
			.getLogger(FCommonCons.class);

	@Override
	public void destroy() {
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		if (logger.isTraceEnabled())
			logger.trace("##### FCommonCons Adding #####");
		
		HttpServletRequest httpRequest = (HttpServletRequest) request;
		httpRequest.setAttribute("JSURL", "/resources/js");
		httpRequest.setAttribute("IMGURL", "/resources/img");
		httpRequest.setAttribute("CSSURL", "/resources/css");
		filterChain.doFilter(httpRequest, response);
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
	}

}
